const http = require("http");
const url = require("url");
const fs = require("fs");
const EventEmiter = require("events");
const path = require("path");

let  MIME = require("./mime.json");

let eventEmiter = new EventEmiter();
require('./routes')(eventEmiter);

const server =http.createServer((req,res)=>{
    //先拿到地址信息
    let path = url.parse(req.url,true).path;
    console.log(path)
    let pathname = url.parse(req.url,true).pathname;
    console.log(pathname);

    if(eventEmiter.listenerCount(pathname)>0){//如果有这个路径的路由监听,就触发路由监听，读取相应页面
        routeEvent.emit(pathname, req, res);
    }else{//若是没有这个路径的路由，

    }
    

}) 

server.listen(8989);

